package com.example.demo.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ItemImageMapper {
    @Insert("insert into item_image (item_id, url, create_time, update_time) values (#{itemId}, #{url}, now(), now())")
    boolean addImage(Long itemId, String url);

    @Select("select url from item_image where item_id = #{itemId} order by id")
    List<String> selectImageUrlByItemId(Long itemId);

    @Select("select url from item_image where item_id = #{itemId} order by id limit 1")
    String selectFirstImageUrlByItemId(Long itemId);

    @Delete("delete from item_image where item_id = #{itemId}")
    boolean deleteImage(Long itemId);
}
